<?php
// +----------------------------------------------------------------------
// | quanli team
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2020 http://www.fistforward.com/ All rights reserved.
// +----------------------------------------------------------------------
// | Author: allen.qiang
// +----------------------------------------------------------------------

/**
 * 会员ajax类
 * @package  ajax
 * @subpackage  backend
 * @author   allen.qiang
 * add by allen.qiang 20150429 TEA-FUN-1003-TEA-下午茶会员导入功能
 */

quanli_require('module/base/customer/quanliCustTea.class.php');

class ajax_customerTea {

    public function execute() {

        if (isset($_REQUEST['operFlg']) && $_REQUEST['operFlg'] > 0) {

            switch($_REQUEST['operFlg']) {

                case 1: //查询会员列表
                    $this->searchCustomerList();
                    break;

                default:
                    returnJsonData('参数错误');
                    break;
            }

        } else {

            returnJsonData('参数错误');

        }

    }

    /**
     * 查询会员信息
     */
//    private function searchCustomer() {
//
//        //实例化会员类
//        $quanliCust = new quanliCust();
//
//        //查询会员信息
//        $customer_array = $quanliCust->searchCustomerDetail( $_REQUEST );
//
//        if ($customer_array) {
//            returnJsonData('ok', 200, $customer_array);
//        } else {
//            returnJsonData('会员信息没有找到', 404);
//        }
//
//    }


    /**
     * 查询会员列表
     */
    private function searchCustomerList() {

        global $G_PGLOB;

        //实例会员类
        $quanliCust = new ebsigCustTea();

        //查询会员信息
        $customer_array = $quanliCust->searchCustomerInfo( $_REQUEST );

        //组织返回的数据
        $result_array = array(
            'page' => $_REQUEST['page'],
            'total' => $_REQUEST['count'],
            'rows' => array()
        );

        if ($customer_array) {

            foreach($customer_array as &$customer) {

                $result_array['rows'][] = array (
                    'id' => $pcustID,
                    'cell' => array(
                        $customer['pcustID'],
                        $customer['custID'],
                        $customer['wx_openID'],
                        $customer['is_right'],
                        $customer['is_treat'],
                        $customer['is_coquetry'],
                        $customer['createTime'],
                        $customer['creator']
                    )
                );
            }
        }

        echo json_encode($result_array);

    }

}